package com.tfswue.jqr.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tfswue.jqr.entity.User;
import com.tfswue.jqr.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/getuser")
    public String getUser()
    {
//        return String.valueOf(userService.getById(1));

        // queryWrapper条件构造器，list()==select * from user where id=? and username = ?
        // queryWrapper.eq("id",1).eq("username","张三");
        // select * from user where id=1 and username="张三"
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",1);
        queryWrapper.like("username","张三");

        List<User> list = userService.list(queryWrapper);
//        return String.valueOf(list);
        return list.toString();
    }
}
